# _*_ coding: utf-8
from .models import Course, Lesson,Video

__author__ = 'hb'
__date__ = '2018/11/20 11:48'
import xadmin


class CourseAdmin(object):
    # name = models.CharField("课程名",max_length=50)
    # desc = models.CharField("课程描述",max_length=300)
    # detail = models.TextField("课程详情")
    # degree = models.CharField('难度',choices=DEGREE_CHOICES, max_length=2)
    # learn_times = models.IntegerField("学习时长(分钟数)",default=0)
    # students = models.IntegerField("学习人数",default=0)
    # fav_nums = models.IntegerField("收藏人数",default=0)
    # image = models.ImageField("封面图",upload_to="courses/%Y/%m",max_length=100)
    # click_nums = models.IntegerField("点击数",default=0)
    # add_time = models.DateTimeField("添加时间",default=datetime.now,)
    list_display = ['name', 'desc', 'detail', 'degree', 'learn_times', 'students', 'fav_nums', 'image', 'click_nums',
                    'add_time']
    search_fields = ['name', 'desc', 'detail', 'degree', 'learn_times', 'students', 'fav_nums', 'image', 'click_nums']
    list_filter = ['name', 'desc', 'detail', 'degree', 'learn_times', 'students', 'fav_nums', 'image', 'click_nums',
                   'add_time']


class LessonAdmin(object):
    list_display = ['course', 'name', 'add_time']

    search_fields = ['course', 'name']
    list_filter = ['course__name', 'name', 'add_time']
class VideoAdmin(object):

    list_display = ['lesson', 'name', 'url',"learn_times","add_time"]

    search_fields = ['lesson', 'name', 'url']
    list_filter = ['lesson', 'name', 'url',"learn_times","add_time"]



xadmin.site.register(Course, CourseAdmin)
xadmin.site.register(Lesson, LessonAdmin)
xadmin.site.register(Video, VideoAdmin)
